Page({
  data: {
    mainActiveIndex: 0,
    activeId: null,
    items: [
      {
        text: '分组 1'
      },
      {
        text: '分组 2'
      },
      {
        text: '分组 3'
      }
    ]
  },

  search() {
    wx.navigateTo({
      url: '/pages/search/search',
    })
  },

  onClickNav({ detail = {} }) {
    this.setData({
      mainActiveIndex: detail.index || 0,
    });
  },

  onClickItem({ detail = {} }) {
    const activeId = this.data.activeId === detail.id ? null : detail.id;

    this.setData({ activeId });
  },

  /**
   * Lifecycle function--Called when page show
   */
  onShow() {
    this.getTabBar().initTabActive()
  }
})